const A = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    aritlesList: [],
    pageNum: 1,
    listHeight: 200,
    activityTypes:[],
  },

  queryElHeight(el){
    let query = wx.createSelectorQuery();
    query.select(el).boundingClientRect(function (res) {
      console.log(res);
      return res.height;
    }).exec();
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.getSystemInfo({
      success: res => {
        console.log(res);
        this.setData({
          listHeight: res.windowHeight
        })
      }
    });
    this.getAritles();
  },
  getAritles() {
    let config = {
      approvalFlag: 1,
      articleType:2,
      enableFlag: 1,
      pageNum: this.data.pageNum++,
      pageSize: 10,
    }
    A.updata.getAritles(config).then(res => {
      this.setData({
        aritlesList: this.data.aritlesList.concat(res.list)
      })
    })
  },

  // 活动详情
  toArticle(e) {
    let id = A.C(e).id;
    console.log(id);
    wx.navigateTo({
      url: `/pages/index/article/article?id=${id}&flag=1`
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getAritles();
  }
})